home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
C-H
/
CHexDmpDA.cpt
/
Hex Dump DA
/
buffer.HexDumpDA.c
< prev
next >
Wrap
Text File
|
1988-05-23
|
944b
|
47 lines
/* buffer.HexDumpDA.c
*
* Routines for managing a window into the contents of a file.
*
* SetBuffer(char *) set the pointer "buffer" to point to a given space
* FillBuffer( start, finish ) assure that the data from offset "start"
* to offset "finish" of the file is in the data buffer
*/
#include <FileMgr.h>
#define BUFSIZE 2048L
char buffer[BUFSIZE];
extern long firstByte;
extern int nLines;
extern int fileRef;
long lmax(a,b)
long a,b;
{
return ((a>b) ? a : b);
}
#define PAD 256L
ReadFrom(i)
long i;
{
/* Maintains buffer and firstByte */
/* Must assure that nLines of data are in buffer */
/* If not:
/* firstByte = max(i-PAD, 0)
/* read BUFSIZE bytes at firstByte
*/
long count;
if ((i<firstByte) || (i + nLines*16>firstByte+BUFSIZE) || (firstByte<0)) {
firstByte = lmax( i-PAD, 0L );
SetFPos( fileRef, fsFromStart, firstByte );
count = BUFSIZE;
FSRead( fileRef, &count, &buffer );
}
}